package com.newlink.building.userinfo.mvp.model

import com.newlink.building.common_base.base.BaseModel
import com.newlink.building.common_base.http.Base_RetrofitHelper
import com.newlink.building.common_base.model.bean.AddFamilyBody
import com.newlink.building.common_base.model.bean.Base_AddFamilyManagementBean
import com.newlink.building.common_base.model.bean.AddFamilyManagementData
import com.newlink.building.common_base.model.bean.AddFamilyMemberRequest
import com.newlink.building.common_base.model.bean.HttpResult
import com.newlink.building.common_base.model.bean.StatusData
import com.newlink.building.userinfo.mvp.contract.Module_UserInfo_FamilyManagementAddContract
import io.reactivex.Observable

/**
 * @author wangyang
 * @date 2022/10/11
 * @description 我的——家庭管理——添加家庭成员页面的Model
 */
class Module_UserInfo_FamilyManagementAddModel : BaseModel(), Module_UserInfo_FamilyManagementAddContract.Model {

    override fun addFamilyManagement(
        token: String,
        addFamilyManagementBean: Base_AddFamilyManagementBean
    ): Observable<HttpResult<AddFamilyManagementData>> {
        return Base_RetrofitHelper.service.addFamilyManagement(token, addFamilyManagementBean)
    }

    override fun addFamilyManagementToKcp(
        token: String,
        addFamilyManagementBean: Base_AddFamilyManagementBean
    ) {
        val addFamilyMemberRequest = AddFamilyMemberRequest(
            accessToken = token,
            uId = "${addFamilyManagementBean.masterUserId}",
            data = AddFamilyBody(
                name = addFamilyManagementBean.name,
                email = addFamilyManagementBean.email,
                qrFlag = addFamilyManagementBean.qrFlag,
                masterUserId = "${addFamilyManagementBean.masterUserId}"
            )

        )
//        KcpTaskHelper.instance.requestAddFamilyMember(addFamilyMemberRequest)
    }

    override fun updateEmail(
        token: String,
        userId: Long,
        email: String,
    ): Observable<HttpResult<StatusData>> {
        return Base_RetrofitHelper.service.updateEmail(token, userId, email)
    }
}